#include <iostream>
#include <string>
#include "yolov3_clip_detector.h"
#include <chrono>
using namespace std;


int main()
{
    //const char * g_omModelPath = "../model/resnet50.om";
    const char * g_omModelPath = "../model/clip_vitb16_static.om";
    //const char * g_omModelPath = "/opt/resource_optical_clip_detector/model/cliptiny_batch.om";
    Yolov3CLIPDetector sampleProcess;
    bool ret = sampleProcess.Initialize(g_omModelPath);
    if (ret != true) {
        std::cout<<"sample init resource failed"<<std::endl;
        return 0;
    }
    
    for (int i=0; i<120; i++){
        cv::Mat img1 = cv::imread("../data/1.jpg");
        ret = sampleProcess.inference(img1);
        if (ret != true) {
            std::cout<<"1111111 :sample process failed"<<std::endl;
            return 0;
        }
    }
    
    int sum_times =0;
    for (int i=0; i<100; i++){
        cv::Mat img1 = cv::imread("../data/1.jpg");
        std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
        ret = sampleProcess.inference(img1);
        std::chrono::high_resolution_clock::time_point t2 = std::chrono::high_resolution_clock::now();
        if (ret != true) {
            std::cout<<"222222:  sample process failed"<<std::endl;
            return 0;
        }
        std::chrono::duration<double, std::milli> time_span = t2 - t1;
        std::cout << "It took " << time_span.count() << " milliseconds."<<std::endl;
        sum_times += time_span.count();
    }
    std::cout<<"100 iters average time: "<<1.0 * sum_times/100<<std::endl;
    std::cout<<"execute sample success"<<std::endl;
    return 1;
}
